package com.founder.android.data;

import java.util.Date;
import java.util.ArrayList;
import java.util.List;

import com.founder.android.parser.Copyable;
import com.founder.android.util.DateUtil;

/**
 * 天气数据
 * @author chen_weihua
 *
 */
public class WeatherInfo extends Copyable {
	
	private String city = "";
	
	private String postalCode = "";
	
	private String latitude = "";
	
	private String longitude = "";
	
	private String problem = "";
	
	private boolean success = true;
	
	private Date currentDateTime = null;
	
	private WeatherCondition currentCondition;
	
	private List<WeatherCondition> forecastConditions;
	
	public WeatherInfo() {
		forecastConditions = new ArrayList<WeatherCondition>();
		currentCondition = new WeatherCondition();
	}
	
	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getPostalCode() {
		return postalCode;
	}

	public void setPostalCode(String postalCode) {
		this.postalCode = postalCode;
	}

	public String getLatitude() {
		return latitude;
	}

	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}

	public String getLongitude() {
		return longitude;
	}

	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}

	public WeatherCondition getCurrentCondition() {
		return currentCondition;
	}

	public void setCurrentCondition(WeatherCondition currentCondition) {
		this.currentCondition = currentCondition;
	}

	public List<WeatherCondition> getForecastConditions() {
		return forecastConditions;
	}

	public void addForecastCondition(WeatherCondition forecastCondition) {
		forecastConditions.add(forecastCondition);
	}

	@Override
	public Object clone() {
		WeatherInfo newWeather = (WeatherInfo)super.clone();
		newWeather.currentCondition = (WeatherCondition)currentCondition.clone();
		List<WeatherCondition> newForecastConditions = new ArrayList<WeatherCondition>();
		for (WeatherCondition condition : forecastConditions) {
			newForecastConditions.add((WeatherCondition)condition.clone());
		}
		newWeather.forecastConditions = newForecastConditions;
		return newWeather;
	}
	
	public void clean() {
		forecastConditions.clear();
	}

	public String getCurrentDateTime() {
		if (currentDateTime == null) {
			return "";
		}
		return DateUtil.dateToString(currentDateTime, "yyyy-MM-dd HH:mm");
	}

	public void setCurrentDateTime(String date) {
		currentDateTime = DateUtil.stringToDate(date, "yyyy-MM-dd HH:mm:ss Z");
	}

	public void setProblem(String problem) {
		this.problem = problem;
	}

	public String getProblem() {
		return problem;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public boolean isSuccess() {
		return success;
	}

}
